<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function fun(a, b, c) {
            var arr2 = [a, b, c];
            for (i = 0; i < arr2.length; i++) {
                console.log(arr2[i]);
                // 找到最小值
                var min = a;
                if (b < min) {
                    min = b;
                    // console.log(b);
                }
                if (c < min) {
                    min = c
                }
                //找到最大值
                var max = a;
                if (b > max) {
                    max = b;
                }
                if (c > max) {
                    max = c;
                }

                //  中间值
                var middle;
                if (min < a && a < max) {
                    middle = a;
                }
                if (min < b && b < max) {
                    middle = b;
                }
                if (min < c && c < max) {
                    middle = c;
                }

            }
            console.log(`最小值是${min},中间值是${middle},最大值是${max}`);

        }
        
        fun(2, 1, 3);
        fun(2, 5, 4);
        fun(2, -3, 4)
    </script>
</body>

</html>